
export const formatRoutes = (routes)=>{
    let fmtRoutes = [];
    routes.forEach(route=>{
        let {
            path,
            component,
            name,
            iconCls,
            children
        } = route;

        if(children && children instanceof  Array){
            children = formatRoutes(children);
        }

        let fmtRoute = {
            name:name,
            path:path,
            iconCls:iconCls,
            children:children,
            component(){
                if(component.startsWith('Home')){
                    return import(`../view/${component}`);
                }else if(component.startsWith('Emp')){
                    return import(`../view/emp/${component}`);
                }else if(component.startsWith('Per')){
                    return import(`../view/per/${component}`);
                }else if(component.startsWith('Sal')){
                    return import(`../view/sal/${component}`);
                }else if(component.startsWith('Sta')){
                    return import(`../view/sta/${component}`);
                }else if(component.startsWith('Sys')){
                    return import(`../view/sys/${component}`);
                }
            }
        };

        fmtRoutes.push(fmtRoute);
    });

    return fmtRoutes;
};
